<h1><?php echo $__title ?></h1>

<?php foreach ($categories AS $category): ?>
<?php if ( !$category->hasForumCredential($__session) ): continue; endif; ?>
<table class="list">
    <thead>
        <tr>
            <th colspan="2"><?php echo $category->getTitle() ?></th>
            <th class="checkbox">Discussions</th>
            <th style="width:200px">Dernier message</th>
        </tr>
    </thead>
    <tbody>
        <?php foreach ($category->getForums() AS $key=>$forum): ?>
        <?php if ( !$forum->hasCredential($__session) ): continue; endif; ?>
        
        <tr <?php if ($key%2>0): ?>class="even"<?php endif; ?>>
            <td style="width:32px"><?php if ($forum->isDiscussionNotRead($__session) ): ?><div class="icons-read"><span class="no-display">Non lu</span></div><?php endif ?></td>
            <td>
                <?php if ( $forum->getImage() != '' ): ?><img class="float-left" style="margin-right:10px;box-shadow:0 0 5px #fff" src="<?php echo $forum->getImage() ?>" alt="Illustration de <?php echo $forum->getTitle() ?>" /><?php endif ?>
                <a class="strong" href="<?php link_to('forum', 'forum', null, array($forum->getId(), slugify($forum->getTitle()))) ?>"><?php echo $forum->getTitle() ?></a><br />
                <p class="no-indent"><?php echo $forum->getDescription() ?></p>
            </td>
            <td class="center"><?php echo $forum->getDiscussions()->count() ?></td>
            <td class="center">
                <?php if ($forum->getDiscussions()->isEmpty()): ?>
                    Aucune discussion
                <?php else: ?>
                    <a class="icon-last" href="<?php link_to('forum', 'discussion', null, array($forum->getDiscussions()->first()->getId(), slugify($forum->getDiscussions()->first()->getTitle()))) ?>#message<?php echo $forum->getDiscussions()->first()->getMessages()->first()->getId() ?>"><?php echo $forum->getDiscussions()->first()->getTitle() ?></a><br />
                    par <?php echo $forum->getDiscussions()->first()->getUser()->getLink() ?>
                <?php endif; ?>
            </td>
        </tr>
        <?php endforeach; ?>
    </tbody>
</table>
<?php endforeach; ?>

<?php if ( $__session->isAuthenticated() ): ?>
<div class="float-left table-list-legend border-radius bg-alpha">
    <div class="titre strong">Légende :</div>
    <div class="icons-read">Messages non lus</div>
</div>

<div class="right" style="margin-top:30px">
    <a href="<?php link_to('forum', 'index', 'read') ?>">Marquer tous les forums comme lus</a>
</div>
<?php endif ?>